package com.flynn.rock.crm.repository.customer;

import com.flynn.rock.crm.convert.AbstractCustomerConvert;
import com.flynn.rock.crm.entity.customer.CustomerOperateRecordEntity;
import com.flynn.rock.model.dto.CustomerOperateRecordDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

@Repository
public interface CustomerOperateRecordRepository extends JpaRepository<CustomerOperateRecordEntity, Long>,
        JpaSpecificationExecutor<CustomerOperateRecordEntity> {

    default CustomerOperateRecordEntity saveCustomerOperateRecord(CustomerOperateRecordDto operateRecordDto) {
        CustomerOperateRecordEntity operateRecord = AbstractCustomerConvert.INSTANCE.toOperateRecordEntity(operateRecordDto);
        return this.save(operateRecord);
    }
}
